﻿using AutoMapper;
using StarsAdmin.Application.Menu.Dtos;
using StarsAdmin.Application.Region.Dtos;
using StarsAdmin.Core.DB.Entities;
using StarsAdmin.Core.Extensions;
using StarsAdmin.Core.Models;

namespace StarsAdmin.Application.Region.Mappings
{
    public class RegionAutoMapperProFile : Profile
    {
        public RegionAutoMapperProFile()
        {
            CreateMap<Page<RegionEntity>, Page<RegionDto>>();
            CreateMap<AddRegionInput, RegionEntity>();
            CreateMap<UpdateRegionInput, RegionEntity>();
            CreateMap<RegionEntity, RegionDto>()
                .ForMember(dest => dest.ParentName, opt => opt.MapFrom(src => src.Parent.Name));
            CreateMap<RegionEntity, ExportRegionDto>()
                .ForMember(dest => dest.ParentName, opt => opt.MapFrom(src => src.Parent.Name))
                .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.Type.GetDescription()));
        }
    }
}